import dayjs from 'dayjs'
export default function () {
	// 默认是关闭状态
	let visible = ref(false)
	// 加载中
	const loading = ref(false)
	// 默认时间
	const defaultDate = dayjs()
	const defaultDateSubtracOneMonth = dayjs().subtract(1, 'month')
	const getYear = () => {
		return defaultDate.year()
	}
	const getMonth = () => {
		return defaultDate.month() + 1
	}
	const yearMonthChange = (date, searchFormState) => {
		if (!date) {
			date = dayjs()
		}
		searchFormState.year = date.year()
		searchFormState.month = date.month() + 1
	}
	/**
	 * 表格高度
	 */
	const scroll = computed(() => {
		return (x) => {
			const height = document.documentElement.clientHeight || document.body.clientHeight
			if (!x) {
				return { y: height > 1000 ? 700 : 480 }
			}
			return { x: x, y: height > 1000 ? 700 : 480 }
		}
	})
	return {
		visible,
		loading,
		defaultDate,
		getYear,
		getMonth,
		yearMonthChange,
		scroll,
		defaultDateSubtracOneMonth
	}
}
